//
//  JQNetworkLog.m
//  JQNetworking
//
//  Created by zhujiaquan on 2018/1/10.
//  Copyright © 2018年 JQ. All rights reserved.
//

#import "JQNetworkLog.h"

@implementation JQNetworkLog

+ (void)logWithRequestUrl:(NSString *)url response:(id)responseObject
{
    NSMutableString *logStr = [NSMutableString stringWithString:@"\n\n"];
    [logStr appendFormat:@"==============================================================\n"];
    [logStr appendFormat:@"=                        API Response                        =\n"];
    [logStr appendFormat:@"==============================================================\n\n"];
    [logStr appendFormat:@"URL: %@\n\n", url];
    [logStr appendFormat:@"%@", responseObject];
    [logStr appendFormat:@"\n\n"];
    [logStr appendFormat:@"==============================================================\n"];
    [logStr appendFormat:@"=                        Response End                        =\n"];
    [logStr appendFormat:@"==============================================================\n\n\n"];
    
    JQNLog(@"%@", logStr);
}

+ (void)logWithRequestUrl:(NSString *)url error:(NSError *)error
{
    NSMutableString *logStr = [NSMutableString stringWithString:@"\n\n"];
    [logStr appendFormat:@"################################################################\n"];
    [logStr appendFormat:@"#                             Error                            #\n"];
    [logStr appendFormat:@"################################################################\n\n"];
    [logStr appendFormat:@"URL: %@\n\n", url];
    [logStr appendFormat:@"Request errCode:%ld, errMsg:%@\n\n", (long)error.code, [error localizedDescription]];
    [logStr appendFormat:@"################################################################\n\n\n"];
    
    JQNLog(@"%@", logStr);
}

@end
